package com.coder520.user.controller;

import com.coder520.user.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2018/5/19.
 */
@Controller("UserController")
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/home")
    public String userHome(){

        return "home";
    }

    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){
        User user = (User) session.getAttribute("USER_SESSION");
        return user;
    }

    //退出登入
    @RequestMapping("logout")
    public String logOut(HttpSession session){
        //清楚用户信息
        session.invalidate();
        return "login";
    }
}
